
const xhr = new XMLHttpRequest()
xhr.open('GET', './data.js', false)
xhr.onreadystatechange = function () {
    if (xhr.readyState === 4) {
        if (xhr.status === 200) {
            alert(xhr.responseText)
        }
    }
}
xhr.send()

// post 请求
const xhr2 = new XMLHttpRequest()
xhr2.open('POST', './data.js', false) 
xhr2.onreadystatechange = function () {
    if (xhr2.readyState === 4) {
        if (xhr2.status === 2) {
            console.log(xhr2.responseText)
        }
    }
}
const people = {
    name: 'zhangsan'
    age: '12'
}